import {findBrandList, findColorList, findTypeList, productInfo} from "@/api/b2c/order";
import pickerOptions from "@/utils/date";

export default {
    name: "index",
    data() {
        return {
            productInfoList: [],
            typeList: [],
            brandList: [],
            colorList: [],
            multipleSelection: [],
            total: 0,
            pickerOptions: pickerOptions,
            searchParams: {
                currentPage: 1,
                pageSize: 8,
                orderProductName: ``,
                typeId: ``,
                brandId: ``,
                modelId: ``,
                colorId: ``,
            },
        }
    },
    methods: {
        async product() {
            let response = await productInfo(this.searchParams)
            console.log(this.searchParams)
            this.productInfoList = response.data
            // console.log(this.productInfoList);
            this.total = response.total
        },
        //页面变化
        currentPageChange(currentIndex) {
            // console.log(currentIndex);
            this.searchParams.currentPage = currentIndex;
            this.product()
        },
        //选择时间
        chooseTime() {
            this.searchParams.startTime = this.pickerOptions.startDate[0];
            this.searchParams.endTime = this.pickerOptions.startDate[1];
        },
        handleSelectionChange(val) {
            this.multipleSelection = val;
        },
        //重置
        resetForm() {
            this.searchParams = {
                currentPage: 1,
                pageSize: 8,
            }
            this.pickerOptions.startDate = '';
            this.product();
        },
        async findColor() {
            this.colorList  = await findColorList();
            this.typeList = await findTypeList();
            this.brandList = await findBrandList()
        }
    },
    created() {
        this.product();
        this.findColor()
    }
}